﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.IO;

namespace Billing.CashDesk
{
    public partial class PrintForm : Billing.WindowsBase.FormBase
    {
       
        List<PrintDoc> printDocs;

        public PrintForm(List<PrintDoc> printDocs)
        {
            InitializeComponent();
            this.printDocs = printDocs;

            foreach (PrintDoc doc in printDocs)
            {
                doc.Key = Guid.NewGuid().ToString();
                doc.PrintControl = new ucPrintControl(doc);
                doc.PrintControl.Dock = DockStyle.Fill;

                Infragistics.Win.UltraWinTabControl.UltraTabPageControl tabPage = new Infragistics.Win.UltraWinTabControl.UltraTabPageControl();
                Infragistics.Win.UltraWinTabControl.UltraTab ultraTab = new Infragistics.Win.UltraWinTabControl.UltraTab();

                ultraTab.Key = doc.Key;
                ultraTab.Text = doc.Name;
                ultraTab.TabPage = tabPage;

                tabPage.Controls.Add(doc.PrintControl);

                ultraTabControl1.Controls.Add(tabPage);
                ultraTabControl1.Tabs.Add(ultraTab);
            }
            this.Load += new EventHandler(PrintForm_Load);
        }

        void PrintForm_Load(object sender, EventArgs e)
        {
            this.WindowState = FormWindowState.Maximized;
            this.StartPosition = FormStartPosition.CenterScreen;
        }

        private void btPrint_Click(object sender, EventArgs e)
        {
            foreach (PrintDoc doc in printDocs)
            {
                doc.PrintControl.Print();
            }
            this.DialogResult = DialogResult.OK;
            this.Close();
        }

    }
}
